package com.lrkj.payfee.controller;

import io.swagger.annotations.ApiOperation;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lrkj.common.annotation.Log;
import com.lrkj.common.core.controller.BaseController;
import com.lrkj.common.core.domain.AjaxResult;
import com.lrkj.common.enums.BusinessType;
import com.lrkj.payfee.domain.ChargeNorm;
import com.lrkj.payfee.service.IChargeNormService;
import com.lrkj.common.utils.poi.ExcelUtil;
import com.lrkj.common.core.page.TableDataInfo;

/**
 * 收费标准Controller
 *
 * @author yajun_ren
 * @date 2021-07-26
 */
@RestController
@RequestMapping("/payfee/norm")
public class ChargeNormController extends BaseController
{
    @Autowired
    private IChargeNormService chargeNormService;

    /**
     * 查询收费标准列表
     */
    @ApiOperation(value = "查询收费标准列表", notes = "查询收费标准列表")
    @GetMapping("/list")
    public TableDataInfo list(ChargeNorm chargeNorm)
    {
        startPage();
        List<ChargeNorm> list = chargeNormService.selectChargeNormList(chargeNorm);
        return getDataTable(list);
    }

    @GetMapping("/listIn")
    public TableDataInfo listIn(ChargeNorm chargeNorm){
        startPage();
        List<ChargeNorm> list = chargeNormService.selectChargeNormIN(chargeNorm);
        return getDataTable(list);
    }

    /**
     * 导出收费标准列表
     */
	@ApiOperation(value = "导出收费标准列表", notes = "导出收费标准列表")
    @PreAuthorize("@ss.hasPermi('payfee:norm:export')")
    @Log(title = "收费标准", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ChargeNorm chargeNorm)
    {
        List<ChargeNorm> list = chargeNormService.selectChargeNormList(chargeNorm);
        ExcelUtil<ChargeNorm> util = new ExcelUtil<ChargeNorm>(ChargeNorm.class);
        return util.exportExcel(list, "收费标准数据");
    }

    /**
     * 获取收费标准详细信息
     */
	@ApiOperation(value = "获取收费标准详细信息", notes = "获取收费标准详细信息")
    @PreAuthorize("@ss.hasPermi('payfee:norm:query')")
    @GetMapping(value = "/{normId}")
    public AjaxResult getInfo(@PathVariable("normId") String normId)
    {
        return AjaxResult.success(chargeNormService.selectChargeNormById(normId));
    }

    /**
     * 新增收费标准
     */
	  @ApiOperation(value = "新增收费标准", notes = "新增收费标准")
    @PreAuthorize("@ss.hasPermi('payfee:norm:add')")
    @Log(title = "收费标准", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ChargeNorm chargeNorm)
    {
        return toAjax(chargeNormService.insertChargeNorm(chargeNorm));
    }

    /**
     * 修改收费标准
     */
	 @ApiOperation(value = "修改收费标准", notes = "修改收费标准")
    @PreAuthorize("@ss.hasPermi('payfee:norm:edit')")
    @Log(title = "收费标准", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ChargeNorm chargeNorm)
    {
        return toAjax(chargeNormService.updateChargeNorm(chargeNorm));
    }

    /**
     * 删除收费标准
     */
	 @ApiOperation(value = "删除收费标准", notes = "删除收费标准")
    @PreAuthorize("@ss.hasPermi('payfee:norm:remove')")
    @Log(title = "收费标准", businessType = BusinessType.DELETE)
	@DeleteMapping("/{normIds}")
    public AjaxResult remove(@PathVariable String[] normIds)
    {
        return toAjax(chargeNormService.deleteChargeNormByIds(normIds));
    }
}
